package thread;

public class SyncDemo3 {
    public static void main(String[] args) {

        Thread t1=new Thread(Boo::doSome);

        Boo b1=new Boo();
        Thread t2=new Thread(()->b1.doSome());

        Thread t3=new Thread(){
            public void run(){
                Boo.doSome();
            }
        };

        Thread t4=new Thread(new Runnable() {
            public void run() {
                Boo.doSome();
            }
        });

        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
class Boo{
    //public synchronized static void doSome(){
    public static void doSome(){
        synchronized (Boo.class) {
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName() + "正在执行");
                Thread.sleep(5000);
                System.out.println(t.getName() + "执行完毕");
            } catch (InterruptedException e) {
            }
        }
    }
}